tests.formatters = {};
tests.formatters.result = function(el, cellVal, opts) {
    $(el).addClass('test-'+cellVal);
    $(el).html(cellVal);
}
tests.formatters.exists = function(el, cellVal, opts) {
    $(el).html(cellVal ? 'Y' : 'N');
    if(!cellVal) {
        $(el).addClass('alert');
    }
}
tests.formatters.time = function(el, cellVal, opts) {
    var r;
    if(cellVal) {
      r = parseFloat(cellVal).toFixed(2);
    }
    else {
      r = '';
    }
    $(el).html(r);
}
tests.formatters.alert = function(el, cellVal, opts) {
    var mark = false;
    $(el).html(cellVal);
    if (opts.colModel.formatoptions.type != undefined && opts.colModel.formatoptions.type == 'lesser') {
        if(parseInt(cellVal) < opts.colModel.formatoptions.value) {
            mark = true;
        }
    }
    else { // greater
        if(cellVal == opts.colModel.formatoptions.value) {
            mark = true;
        }
    }
    if(mark) {
        $(el).addClass('alert');
    }
}
tests.formatters.cmd = function(el, cellVal, opts) {
    dbg = opts;
    if( $(dbg.rowData.cells[8]).html() == "Y" ) {
        var r = "<button type='button' onclick='tests.tests.runTest(" + opts.rowId + ");'>run</button> &nbsp;"
        + "<button type='button' onclick='tests.tests.runClassTests(" + opts.rowId + ");'>run class</button>&nbsp;"
        + "<button type='button' onclick='tests.tests.openTest(" + opts.rowId + ");'>open</button>&nbsp;";
    }
    else {
        var r = "<button type='button' onclick='tests.tests.writeInFile(" + opts.rowId + ");'>write in file</button> &nbsp;"
        + "<button type='button' onclick='tests.tests.removeFromDatabase(" + opts.rowId + ");'>remove from db</button> &nbsp;";
    }
    if( $(dbg.rowData.cells[3]).html() == "ERROR" ) {
        r += "<button type='button' onclick='tests.tests.showError({id : " + opts.rowId + "});'>err</button>";
    }
    $(el).html(r);
}